import billsAPI from "@/api/coins/bills-api";

export const useBalance = () => {
  const balanceTotal = ref(0);
  const quotasTotal = ref(0);
  const loading = ref(false);
  async function getBalanceTotal() {
    try {
      loading.value = true;
      const res: any = await billsAPI.getBalanceTotal();
      balanceTotal.value = res.data.points || 0;
      quotasTotal.value = res.data.quotas;
    } catch (e) {
      console.log(e);
    } finally {
      loading.value = false;
    }
  }
  onBeforeMount(() => {
    getBalanceTotal();
  });
  return {
    balanceTotal,
    quotasTotal,
    loading,
    getBalanceTotal,
  };
};
